<!DOCTYPE html>
<html>

<head>
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta charset="utf-8" />
  <meta name="renderer" content="webkit" />
  <meta name="keywords" content="" />
  <meta name="description" content="" />
  <meta name="author" content="" />
  <title></title>
  <link href="css/daterangepicker.min.css" rel="stylesheet" />
  <link rel="stylesheet" href="css/main.css" />
  <link rel="stylesheet" href="enterpriseCommon/common.css">
  <link rel="shortcut icon" href="favicon.ico" />
  <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css" />
  <style>
    [v-cloak] {
      display: none;
    }

  </style>
  <script src="js/vue.js"></script>
  <!--[if lt IE 9]>
      <script src="js/html5shiv.min.js"></script>
      <script src="js/respond.min.js"></script>
    <![endif]-->
</head>

<body>
  <div id="app" v-cloak>
    <header>
    </header>
    <div class="header-space"></div>

    <section class="section302">
      <div class="content">
        <div class="left">
          <div class="l">浏览招聘时间：5小时前</div>
          <div class="r">下载简历可查看联系方式</div>
        </div>
      </div>
    </section>

    <section class="g-main">
      <div class="content">
        <div class="main-left w780">
          <section class="section-resume section301">
            <div class="resume-info">
              <div class="box">
                <div class="left">
                  <div class="name">{{person_info.name}}</div>
                  <ul class="list">
                    <li>{{person_info.sex | sexFilter}} | {{person_info.age}}岁 | {{person_info.education}} | {{person_info.area}} | {{experience}}年 | {{resume_info.status_id|statusFilter}}
                    </li>
                    <li class="w50">电话：{{person_info.telephone}}</li>
                    <li class="w50">邮箱：{{person_info.email}}</li>
                    <li>语言：{{person_info.language}}</li>
                  </ul>
                  <div class="tags">
                    <span v-for="(tagItem, tagIndex) in person_info.person_tag" :key="tagIndex" class="tag tag-blue">{{ tagItem.name }}</span>
                  </div>
                </div>
                <div class="right w200">
                  <span class="btns" @click="collectHandle"><img :src="'images/hart'+(is_collect?'-on': '')+'.png'" alt="" />{{is_collect?'取消': ''}}收藏</span>
                  <span class="btns" @click="reportHandle"><img src="images/warn.png" alt="" />举报</span>
                </div>
              </div>
            </div>
            <div class="resume-box resume-box1">
              <div class="title-line">求职意向</div>
              <ul class="list">
                <li class="w50">期望职位：{{resume_info.position}}</li>
                <li class="w50">工作性质：{{resume_info.nature}}</li>
                <li class="w50">工作地点：{{resume_info.area}}</li>
                <li class="w50">期望薪资：{{resume_info.salary_min}}~{{resume_info.salary_max}}</li>
              </ul>
            </div>
            <div class="resume-box resume-box2">
              <div class="title-line">工作经验</div>
              <div class="list-works">
                <div v-for="(workItem, workIndex) in work_experience" :key="workIndex" class="item">
                  <div class="title-small">
                    <span class="name">{{ workItem.name }}</span><small>{{ workItem.start}}～{{workItem.end}}（{{workItem.time}}年）</small>
                  </div>
                  <div class="sub-title">
                    <span>{{ workItem.position }}</span>|<span>税前{{ workItem.salary }}</span>
                  </div>
                  <div class="con">
                    {{workItem.desc}}
                  </div>
                  <div class="tags">
                    <span v-for="(tagItem, tagIndex) in workItem.trade" :key="tagIndex" class="tag tag-gray">{{tagItem}}</span>
                  </div>
                </div>
              </div>
            </div>
            <div class="resume-box resume-box3">
              <div class="title-line">教育经历</div>
              <div class="list-teach">
                <div v-for="(educationItem, educationIndex) in education_experience" :key="educationIndex" class="item">
                  <div class="title-small">
                    <span class="name">{{educationItem.name}}</span><small>{{educationItem.start}}～{{educationItem.end}}（{{educationItem.time}}年）</small>
                  </div>
                  <div class="sub-title">
                    <span>{{educationItem.major}}</span>|<span>{{educationItem.education}}</span>
                  </div>
                  <div class="con">
                    <p>{{educationItem.desc}}</p>
                  </div>
                </div>
              </div>
            </div>
            <div class="resume-box resume-box4">
              <div class="title-line">学历认证</div>
              <div class="list-card">
                <div class="item">
                  <div class="img-box">
                    <div class="img">
                      <img :src="education_certificate[0]" alt="" class="cover" />
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div class="resume-box resume-box5">
              <div class="title-line">个人作品</div>
              <div class="list-product">
                <div class="item">
                  <div class="img-box-more">
                    <div v-for="(workImgItem, workImgIndex) in person_works" :key="workImgIndex" class="img">
                      <img :src="workImgItem" alt="" class="cover" />
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div class="resume-box resume-box6">
              <div class="title-line">自我评价</div>
              <div class="list-info">
                <div class="item">
                  <div class="con">
                    {{person_desc}}
                  </div>
                </div>
              </div>
            </div>
          </section>
        </div>
        <div class="main-right">
          <div class="g-user auto">
            <img :src="person_info.image" alt="" class="face" />
            <h3>{{person_info.name}}</h3>
            <div class="detail">
              <h4>简历摘要</h4>
              <div v-for="(workItem, workIndex) in work_experience" :key="workIndex" class="item">
                <div class="time">{{ workItem.start}}～{{workItem.end}}（{{workItem.time}}年）</div>
                <div class="name">{{ workItem.name }}</div>
                <div class="tags"><span v-for="(tagItem, tagIndex) in workItem.trade" :key="tagIndex">{{tagItem}}</span>
                </div>
              </div>
            </div>
            <div class="operate">
              <a :href="'./39.html?id='+resume_type.uid" class="btn btn-white">打招呼</a>
              <a href="javascript:void(0)" class="btn" @click="interviewHandle(index, 0)">邀面试</a>
            </div>
          </div>

          <div class="g-sideDown">
            <a href="javascript:void(0)" class="btn" @click="downLoadHandle">下载简历</a>
          </div>
        </div>
      </div>
    </section>

    <pop-interview v-if="isShowIterview" :id="editId" :type="editType" :uid="editUid" @cancel="cancelHandle" @sure="cancelHandle"></pop-interview>
    <!-- <report v-show="isShowReport" :show.sync="isShowReport" type=""></report> -->
    <footer>
    </footer>
  </div>
  <script src="js/jquery.min.js"></script>
  <script src="js/slide.min.js"></script>
  <script src="js/polyfill.min.js"></script>
  <script src="js/jquery.nicescroll3.7.6.min.js"></script>
  <script src="js/main.js"></script>
  <script src="https://unpkg.com/element-ui/lib/index.js"></script>
  <script src="js/request.js"></script>
  <script src="js/getPrepareData.js"></script>
  <script src="js/popComponents.js"></script>
  <script src="js/reportComponent.js"></script>
  <script>
    $(function() {
      $("header").load("./enterpriseCommon/header.html");
      $("footer").load("./enterpriseCommon/footer.html");
    })
  </script>
  <script>
    function getTime(item) {
      var startStr = item.start;
      var endStr = item.end;
      var startDate = new Date(/\d/.test(startStr) ? startStr : Date.now());
      var endDate = new Date(/\d/.test(endStr) ? endStr : Date.now());
      var year = endDate.getFullYear() - startDate.getFullYear();
      var month = endDate.getMonth() - startDate.getMonth();
      var btYear = Math.round(month / 6) * 0.5;
      return year + btYear
    }
    var vm = new Vue({
      el: '#app',
      data: {
        person_info: {
          "image": "",
          "name": "",
          "sex": 1,
          "age": 0,
          "area_id": 1,
          "telephone": "",
          "email": "",
          "id_card": "",
          "person_tag": [],
          "language": []
        },
        resume_info: {},
        work_experience: [],
        education_experience: [],
        "education_certificate": [],
        "person_works": [],
        "person_desc": "",
        "resume_type": {
          "language": 1,
          "hidden": 0
        },
        experience: 0,
        is_collect: false,
        isShowIterview: false,
        editType: 1, // 1添加 ，取消面试
        editId: 0, // 编辑等操作时的id
        editUid: 0 // 编辑等操作是用户的id
      },
      created: function() {
        prepare.getEnterPriseResumeData(this.getResume.bind(this))
      },
      methods: {
        getResume: function() {
          var id = getUrlParams().id || 0
          request(
            "enterprise/index/user_recruit/" + id,
            "GET", '',
            success.bind(this),
            fail.bind(this)
          );

          function success(res) {
            var data = res.data;
            this.person_info = data.person_info;
            this.resume_info = data.resume_info;
            this.work_experience = data.work_experience;
            this.education_experience = data.education_experience;
            this.education_certificate = data.education_certificate;
            this.person_works = data.person_works;
            this.person_desc = data.person_desc;
            this.resume_type = data.resume_type;
            this.is_collect = data.is_collect;
            
            this.editUid = data.resume_type.uid;
            this.editId = data.resume_type.id;
            this.filterData()
          }

          function fail(err) {
            this.$message('获取简历失败')
            console.log('err', err);
          }
        },
        filterData: function() {
          // 根据id查找数据
          var personInfo = this.person_info;
          var resumeInfo = this.resume_info;
          var workExperience = this.work_experience;
          var educationExperience = this.education_experience;
          personInfo.area = prepare.getRegionNameList(personInfo.area_id).slice(-1)[0];
          personInfo.language = personInfo.language.reduce(function(result, item) {
            result += (prepare.getLanguageName(item.language_id) + '|' + prepare.getAbilityName(item.ability_id))
            return result
          }, '');
          personInfo.person_tag.forEach(function(item) {
            item.name = prepare.getTagName(item.tag_id)
          });

          resumeInfo.nature = prepare.getNatureName(resumeInfo.nature_id);
          resumeInfo.position = prepare.getPositionNameList(resumeInfo.position_id).join('-');
          resumeInfo.area = prepare.getRegionNameList(resumeInfo.area_id).join('-');
          this.experience = prepare.getExperienceName(resumeInfo.experience_config_id)

          workExperience.forEach(function(item) {
            // item.position = prepare.getPositionNameList(item.position_id).join('-')
            item.time = getTime(item);
            item.trade = prepare.getTradeNameList(item.trade_id);
          })
          
          educationExperience.sort(function(a,b) {return b.id - a.id});
          educationExperience.forEach(function(item) {
            item.education = prepare.getEducationName(item.education_id)
            item.time = getTime(item);
          })
          
          personInfo.education = educationExperience[0]? educationExperience[0].education : '无学历'

        },
        // 下载简历
        downLoadHandle: function() {

          var self = this;
          request('enterprise/user/resume/download', 'POST', JSON.stringify({
            id: [this.editUid]
          }), function(res) {

            window.open(res.data.url)
          }, function(err) {
            sefl.$message.error(err.responseJSON ? err.responseJSON.message : '下载失败')
          })
          // this.$message('功能暂未开放')
        },
        // 收藏
        collectHandle: function() {
          var item = this;
          request('enterprise/resume/collect', item.is_collect ? 'DELETE' : 'POST', JSON.stringify({
            user_id: item.uid
          }), success.bind(this))

          function success(res) {
            this.$message.success(res.message)
            this.$set(item, 'is_collect', !item.is_collect)
          }
        },
        // 举报
        reportHandle: function() {
          location.href = "./27.html"
        },

        // 邀请面试，编辑面试
        interviewHandle: function(index, type) {
          this.isShowIterview = true;
          this.editType = type;
        },
        // 关闭弹窗
        cancelHandle: function() {
          this.isShowIterview = false;
        },
      },
      filters: {
        sexFilter: function(sexType) {
          return ({
            0: '女',
            1: '男'
          })[sexType]
        },
        statusFilter: function(id) {
          return prepare.getStatusName(id)
        }
      }
    })

  </script>
</body>

</html>
